package cn.quang.search.admin.utils;

import lombok.extern.slf4j.Slf4j;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

@Slf4j
public class DbUtils {
    public static void closeConnection(Connection connection) {
        if (connection != null) {
            try {
                connection.close();
            } catch (SQLException var2) {
                log.info("Could not close JDBC Connection", var2);
            } catch (Throwable var3) {
                log.info("Unexpected exception on closing JDBC Connection", var3);
            }

        }
    }

    public static void closeStatement(Statement stmt) {
        if (stmt != null) {
            try {
                stmt.close();
            } catch (SQLException var2) {
                log.info("Could not close JDBC Statement", var2);
            } catch (Throwable var3) {
                log.info("Unexpected exception on closing JDBC Statement", var3);
            }

        }
    }

    public static void closeResultSet(ResultSet rs) {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException var2) {
                log.info("Could not close JDBC ResultSet", var2);
            } catch (Throwable var3) {
                log.info("Unexpected exception on closing JDBC ResultSet", var3);
            }

        }
    }

    public static void close(ResultSet rs, Statement stmt, Connection connection) {
        closeResultSet(rs);
        closeStatement(stmt);
        closeConnection(connection);
    }
}
